<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<script type="text/javascript">
$(document).ready(function() {
	$("#qry_grid").jqGrid( {
		url : '<c:url value="/json/brandList.do"/>',
		mtype : "POST",
		datatype : "json",
		colNames : [ '品牌代码', '品牌名称'], //
		colModel : [ {
			name : 'brandId',
			index : 'brandId',
			width : 100,
			key : true
		}, {
			name : 'brandName',
			index : 'brandName',
			width : 350
		}],
		jsonReader : {
			root : "objList",
			cell : "",
			repeatitems : false,
			id : "uuid"
		},
		rowNum : 10,
		rowList : [ 10, 20, 30 ],
		pager : '#qry_pager',
		sortname : 'brandId',
		viewrecords : true,
		sortorder : "asc",
		caption : "搜索结果",
		ondblClickRow : function(rowid, iRow, iCol, e) {
			qry_select();
		}
	});
	$("#qry_gridpager").jqGrid('navGrid', '#qry_pager', {
		edit : false,
		add : false,
		del : false,
		search : false,
		refresh : false
	});
});

function qry_search() {
	var qry_brandID = $("#qry_brandID").val();
	var qry_brandName = $("#qry_brandName").val();
	$("#qry_grid").jqGrid('setGridParam', {
		postData : {
			"paramMap['brandId']" : qry_brandID,
			"paramMap['brandName']" : qry_brandName
		},
		page : 1
	}).trigger("reloadGrid");
}

function qry_select() {
	var objId = $("#qry_grid").getGridParam('selrow');
	try {
		if (objId) {
			if($("#brandIdParam"))
				$("#brandIdParam").val($("#qry_grid").jqGrid('getCell', objId, 0));
			if($("#brandName"))
				$("#brandName").val($("#qry_grid").jqGrid('getCell', objId, 1));
			closeDialog();
		} else {
			alert("请选择品牌");
		}
	} catch (e) {
		alert(e);
	}	
	
}

</script>

<div id="qry_dialog" title="搜索品牌">
<table width="350px">
	<tr>
		<td style="width: 95px;">品牌代码</td>
		<td><input name="qry_brandID" type="text" id="qry_brandID" size="15" /></td>
	</tr>
	<tr>
		<td style="width: 95px;">品牌名称</td>
		<td><input name="qry_brandName" type="text" id="qry_brandName" size="30" /></td>
	</tr>
	<tr>
		<td colspan="2" align="center">
		<div class="f-link"><a href="javascript:void(0);" onclick=qry_search();return false;>搜索</a></div>
		</td>
	</tr>
	<tr>
		<td colspan="2">
		<table id="qry_grid"></table>
		<div id="qry_pager"></div>
		</td>
	</tr>
	<tr>
		<td colspan="2" align="center">
		<div class="f-link"><a href="javascript:void(0);" onclick=qry_select();return false;>选择品牌</a></div>
		</td>
	</tr>
</table>
</div>